<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库管理</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script src="js/page.js"></script>
<script type="text/javascript">
<!--
function submitHandler()
{
	if (document.getElementById("table_name").value.replace(/(^\s*)|(\s*$)/g, "") == "")
	{
		window.alert("请输入数据表名称！");
		document.getElementById("table_name").focus();
	}
	else
		document.getElementById("form_insert").submit();
	return false;
}
//-->
</script>
</head>

<body onload="initialize();document.getElementById('table_name').focus();">
<jsp:useBean id="database" class="DatabaseConnection.DatabaseConnection" />
<%@include file="connect_database.jsp" %>
<%
request.setCharacterEncoding("utf-8");
String database_name = request.getParameter("database");
String sql_check_database = "show databases like '" + database_name + "';";
ResultSet resultset_check_database = database.executeQuery(sql_check_database);
if (resultset_check_database != null && resultset_check_database.next() == true)
{
%>
<div style="padding-top:20px" />
<div align="center"><font size="+1"><strong>添加数据表</strong></font></div>
<br />
<form id="form_insert" name="form_insert" method="post" action="tables_insert_first_do.jsp?database=<%= database_name %>" onsubmit="return submitHandler();">
  <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#B1C8D7">
    <tr align="center" bgcolor="#F4F4FF">
      <td height="24"><strong>请输入数据表名称</strong></td>
    </tr>
    <tr align="center" bgcolor="#FFFFFF">
      <td height="30"><input name="table_name" type="text" id="table_name" size="25" /></td>
    </tr>
    <tr align="center" bgcolor="#F4F4FF">
      <td height="24">
        <input name="ok" type="submit" class="input_button" id="ok" value="确定" />
        　
        <input name="back" type="button" class="input_button" id="back" onclick="window.location.href='tables.jsp?database=<%= database_name %>';" value="返回" />
      </td>
    </tr>
  </table>
</form>
<%
}
else
{
%>
<script type="text/javascript">
<!--
	window.alert("连接数据库 <%= database_name %> 失败！");
	window.location.href = "databases.jsp";
//-->
</script>
<%
}
if (resultset_check_database != null)
	resultset_check_database.close();
database.closeConnection();
%>
</body>
</html>